package edu.pinkhub.shiro_test.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import edu.pinkhub.shiro_test.entity.Users;
import edu.pinkhub.shiro_test.service.UsersService;
import edu.pinkhub.shiro_test.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@RequestMapping("/users")
@Controller
public class UsersControlller {

    @Autowired
    private UsersService service;
    @RequestMapping("/list")
    @ResponseBody
    public R usersList(Integer page,Integer limit){
        Integer start=(page-1)*limit;
        Integer offset=3;
        QueryWrapper<Users> wrapper=new QueryWrapper<>();
        wrapper.last(" limit "+start+" , "+offset);
        List<Users> list = service.list(wrapper);
        long count = service.count();
        R r=new R();
        r.put("msg"," ");
        r.put("code","0");
        r.put("data",list);
        r.put("count",count);
        return r;
    }

}
